<?php
/**
 * ZView
 *
 * Zend Frameworks View Component for TYPO3
 *
 * @package    ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */

/** Abstract class for extension */
require_once 'Zend/View/Helper/Abstract.php';

require_once('Zend/Registry.php');
require_once('Zend/Locale.php');
require_once('Zend/Date.php');

/**
 * Helper to generate an "url" (using for the href attribute)
 *
 * @package ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */
class Tx_Zview_Helper_T3date extends Zend_View_Helper_Abstract
{

	/**
	 * Returns a formatted date.
	 *
	 * @param string $format
	 * @param string $timestamp
	 * @return unknown
	 */
	public function t3date($format, $timestamp=null)
	{
		if(empty($timestamp)) {
			$timestamp = time();
		}
		if(Zend_Registry::isRegistered('Zend_Locale')) {
			$locale = Zend_Registry::get('Zend_Locale');
		} else {
			$locale = new Zend_Locale();
		}
		$date = new Zend_Date($timestamp, null, $locale);
		return htmlentities(utf8_decode($date->get($format)));
	}

}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3date.php']) {
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3date.php']);
}
